home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / ActiveX Controlls / DVD Writer Pro ActiveX Control / DVD Writer Pro ActiveX Control.exe / %MAINDIR% / VBSample1 / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2003-04-16  |  52.6 KB  |  1,341 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  4. Object = "{76EE42AB-1020-49E7-B70A-B4357329854D}#1.0#0"; "DVDRProX.dll"
  5. Begin VB.Form frmMain 
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "DVDWriterPro Sample1"
  8.    ClientHeight    =   7620
  9.    ClientLeft      =   150
  10.    ClientTop       =   435
  11.    ClientWidth     =   8685
  12.    Icon            =   "frmMain.frx":0000
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   7620
  16.    ScaleWidth      =   8685
  17.    StartUpPosition =   1  'CenterOwner
  18.    Begin VB.Frame fraWriteOptions 
  19.       Caption         =   "Write Options"
  20.       Height          =   1560
  21.       Left            =   4185
  22.       TabIndex        =   16
  23.       Top             =   5145
  24.       Width           =   4395
  25.       Begin VB.CheckBox chkTestWrite 
  26.          Caption         =   "Test Write (Invalid for DVD Formats)"
  27.          Height          =   315
  28.          Left            =   105
  29.          TabIndex        =   20
  30.          ToolTipText     =   "Not valid for DVD formats."
  31.          Top             =   825
  32.          Width           =   4170
  33.       End
  34.       Begin VB.CheckBox chkFinalizeDisc 
  35.          Caption         =   "Finalize Disc (No Further Writing Possible)"
  36.          Height          =   315
  37.          Left            =   105
  38.          TabIndex        =   19
  39.          ToolTipText     =   "Not valid for DVD+RW and DVD-RAM formats."
  40.          Top             =   570
  41.          Width           =   3840
  42.       End
  43.       Begin VB.CheckBox chkCacheImage 
  44.          Caption         =   "Cache Image Before Writing (CDR/W Only)"
  45.          Height          =   315
  46.          Left            =   105
  47.          TabIndex        =   18
  48.          ToolTipText     =   "Not needed for DVD formats...Use for CDR/W only."
  49.          Top             =   300
  50.          Width           =   4185
  51.       End
  52.       Begin VB.CheckBox chkUseBurnProof 
  53.          Caption         =   "Use Buffer Protection (Burn Proof,JustLink,etc.)"
  54.          Height          =   315
  55.          Left            =   105
  56.          TabIndex        =   17
  57.          ToolTipText     =   "Eliminates buffer underrun problems."
  58.          Top             =   1110
  59.          Width           =   4170
  60.       End
  61.    End
  62.    Begin VB.Frame fraImageOptions 
  63.       Caption         =   "Data Options"
  64.       Height          =   1560
  65.       Left            =   15
  66.       TabIndex        =   13
  67.       Top             =   5145
  68.       Width           =   4050
  69.       Begin VB.CheckBox chkUseMode2XA 
  70.          Caption         =   "Mode2XA instead of Mode1 (CDR/W Only)"
  71.          Height          =   195
  72.          Left            =   165
  73.          TabIndex        =   23
  74.          ToolTipText     =   "Please see help file for details on Mode2XA"
  75.          Top             =   900
  76.          Width           =   3555
  77.       End
  78.       Begin VB.CheckBox chkDVDHighCompMode 
  79.          Caption         =   "DVD High Compatibility (Write at least 1GB)"
  80.          Height          =   195
  81.          Left            =   165
  82.          TabIndex        =   22
  83.          ToolTipText     =   "Please see help file for details for DVD High Compatibility property."
  84.          Top             =   1170
  85.          Width           =   3555
  86.       End
  87.       Begin VB.CheckBox chkUseJoliet 
  88.          Caption         =   "Include Joliet Directories (64 char file names)"
  89.          Height          =   195
  90.          Left            =   165
  91.          TabIndex        =   21
  92.          Top             =   645
  93.          Value           =   1  'Checked
  94.          Width           =   3555
  95.       End
  96.       Begin VB.TextBox txtVolIdentifier 
  97.          Height          =   300
  98.          Left            =   1005
  99.          MaxLength       =   32
  100.          TabIndex        =   14
  101.          Text            =   "New Disc"
  102.          Top             =   270
  103.          Width           =   2580
  104.       End
  105.       Begin VB.Label lblVolIdentifier 
  106.          Caption         =   "Volume ID:"
  107.          Height          =   255
  108.          Left            =   120
  109.          TabIndex        =   15
  110.          Top             =   330
  111.          Width           =   855
  112.       End
  113.    End
  114.    Begin VB.PictureBox picSplitter 
  115.       BackColor       =   &H00808080&
  116.       BorderStyle     =   0  'None
  117.       FillColor       =   &H00808080&
  118.       Height          =   4335
  119.       Left            =   3465
  120.       ScaleHeight     =   1887.645
  121.       ScaleMode       =   0  'User
  122.       ScaleWidth      =   1248
  123.       TabIndex        =   9
  124.       Top             =   750
  125.       Visible         =   0   'False
  126.       Width           =   120
  127.    End
  128.    Begin MSComDlg.CommonDialog CommonDialog1 
  129.       Left            =   7155
  130.       Top             =   0
  131.       _ExtentX        =   847
  132.       _ExtentY        =   847
  133.       _Version        =   393216
  134.    End
  135.    Begin VB.CommandButton cmdCancel 
  136.       Caption         =   "&Cancel"
  137.       Height          =   375
  138.       Left            =   1665
  139.       TabIndex        =   8
  140.       Top             =   6833
  141.       Width           =   1500
  142.    End
  143.    Begin VB.CommandButton cmdWriteDisc 
  144.       Caption         =   "&Write Disc"
  145.       Height          =   375
  146.       Left            =   90
  147.       TabIndex        =   7
  148.       Top             =   6833
  149.       Width           =   1500
  150.    End
  151.    Begin MSComctlLib.StatusBar sbrStatus 
  152.       Align           =   2  'Align Bottom
  153.       Height          =   345
  154.       Left            =   0
  155.       TabIndex        =   6
  156.       Top             =   7275
  157.       Width           =   8685
  158.       _ExtentX        =   15319
  159.       _ExtentY        =   609
  160.       SimpleText      =   "Add Audio Files"
  161.       _Version        =   393216
  162.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  163.          NumPanels       =   3
  164.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  165.             AutoSize        =   1
  166.             Object.Width           =   8784
  167.          EndProperty
  168.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  169.             Object.Width           =   3881
  170.             MinWidth        =   3881
  171.          EndProperty
  172.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  173.          EndProperty
  174.       EndProperty
  175.    End
  176.    Begin VB.ComboBox cboDevices 
  177.       Height          =   315
  178.       Left            =   525
  179.       Style           =   2  'Dropdown List
  180.       TabIndex        =   2
  181.       Top             =   90
  182.       Width           =   2835
  183.    End
  184.    Begin VB.ComboBox cboWriteSpeed 
  185.       Height          =   315
  186.       Left            =   4530
  187.       Style           =   2  'Dropdown List
  188.       TabIndex        =   0
  189.       Top             =   75
  190.       Width           =   1095
  191.    End
  192.    Begin MSComctlLib.ProgressBar prgTotalProgress 
  193.       Height          =   300
  194.       Left            =   4185
  195.       TabIndex        =   4
  196.       Top             =   6870
  197.       Width           =   4395
  198.       _ExtentX        =   7752
  199.       _ExtentY        =   529
  200.       _Version        =   393216
  201.       Appearance      =   1
  202.       Scrolling       =   1
  203.    End
  204.    Begin MSComctlLib.ImageList ImageList1 
  205.       Left            =   7710
  206.       Top             =   -15
  207.       _ExtentX        =   1005
  208.       _ExtentY        =   1005
  209.       BackColor       =   -2147483643
  210.       ImageWidth      =   16
  211.       ImageHeight     =   16
  212.       MaskColor       =   12632256
  213.       _Version        =   393216
  214.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  215.          NumListImages   =   4
  216.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  217.             Picture         =   "frmMain.frx":0442
  218.             Key             =   "CLOSEDFOLDER"
  219.          EndProperty
  220.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  221.             Picture         =   "frmMain.frx":0894
  222.             Key             =   "CD"
  223.          EndProperty
  224.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  225.             Picture         =   "frmMain.frx":0CE6
  226.             Key             =   "OPENFOLDER"
  227.          EndProperty
  228.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  229.             Picture         =   "frmMain.frx":1138
  230.             Key             =   "FILE"
  231.          EndProperty
  232.       EndProperty
  233.    End
  234.    Begin MSComctlLib.ListView lvwImageFiles 
  235.       Height          =   4335
  236.       Left            =   3630
  237.       TabIndex        =   10
  238.       Top             =   765
  239.       Width           =   4950
  240.       _ExtentX        =   8731
  241.       _ExtentY        =   7646
  242.       View            =   3
  243.       LabelEdit       =   1
  244.       Sorted          =   -1  'True
  245.       LabelWrap       =   -1  'True
  246.       HideSelection   =   -1  'True
  247.       OLEDragMode     =   1
  248.       OLEDropMode     =   1
  249.       _Version        =   393217
  250.       Icons           =   "ImageList1"
  251.       SmallIcons      =   "ImageList1"
  252.       ForeColor       =   -2147483640
  253.       BackColor       =   -2147483643
  254.       BorderStyle     =   1
  255.       Appearance      =   1
  256.       OLEDragMode     =   1
  257.       OLEDropMode     =   1
  258.       NumItems        =   3
  259.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  260.          Text            =   "File Name"
  261.          Object.Width           =   4410
  262.       EndProperty
  263.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  264.          Alignment       =   1
  265.          SubItemIndex    =   1
  266.          Text            =   "Size"
  267.          Object.Width           =   2540
  268.       EndProperty
  269.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  270.          SubItemIndex    =   2
  271.          Text            =   "Date"
  272.          Object.Width           =   3881
  273.       EndProperty
  274.    End
  275.    Begin MSComctlLib.TreeView tvwDirectories 
  276.       DragIcon        =   "frmMain.frx":158A
  277.       Height          =   4335
  278.       Left            =   60
  279.       TabIndex        =   11
  280.       Top             =   750
  281.       Width           =   3195
  282.       _ExtentX        =   5636
  283.       _ExtentY        =   7646
  284.       _Version        =   393217
  285.       Indentation     =   353
  286.       LabelEdit       =   1
  287.       Sorted          =   -1  'True
  288.       Style           =   7
  289.       Appearance      =   1
  290.       OLEDragMode     =   1
  291.       OLEDropMode     =   1
  292.    End
  293.    Begin DVDRPROXLibCtl.DVDWriterPro DVDWriterPro1 
  294.       Left            =   6510
  295.       OleObjectBlob   =   "frmMain.frx":19CC
  296.       Top             =   0
  297.    End
  298.    Begin VB.Line Line1 
  299.       BorderColor     =   &H00000000&
  300.       X1              =   30
  301.       X2              =   8670
  302.       Y1              =   0
  303.       Y2              =   0
  304.    End
  305.    Begin VB.Label lblImageFileTitle 
  306.       BorderStyle     =   1  'Fixed Single
  307.       Caption         =   "Image Files - Drag and Drop Files or Folders"
  308.       Height          =   270
  309.       Left            =   45
  310.       TabIndex        =   12
  311.       Top             =   450
  312.       Width           =   8535
  313.    End
  314.    Begin VB.Image imgSplitter 
  315.       Height          =   4335
  316.       Left            =   3300
  317.       MousePointer    =   9  'Size W E
  318.       Top             =   750
  319.       Width           =   90
  320.    End
  321.    Begin VB.Label lblTotalWritten 
  322.       Caption         =   "Written:"
  323.       Height          =   285
  324.       Left            =   3570
  325.       TabIndex        =   5
  326.       Top             =   6878
  327.       Width           =   645
  328.    End
  329.    Begin VB.Label lblRecorder 
  330.       Alignment       =   1  'Right Justify
  331.       Caption         =   "Drive:"
  332.       Height          =   225
  333.       Left            =   -225
  334.       TabIndex        =   3
  335.       Top             =   120
  336.       Width           =   720
  337.    End
  338.    Begin VB.Label lblWriteSpeed 
  339.       Alignment       =   1  'Right Justify
  340.       Caption         =   "Write Speed"
  341.       Height          =   255
  342.       Left            =   3495
  343.       TabIndex        =   1
  344.       Top             =   135
  345.       Width           =   975
  346.    End
  347.    Begin VB.Menu mnuFile 
  348.       Caption         =   "&File"
  349.       Begin VB.Menu mnuFileClear 
  350.          Caption         =   "Clear All Items"
  351.          Shortcut        =   ^C
  352.       End
  353.       Begin VB.Menu mnuFileSep1 
  354.          Caption         =   "-"
  355.       End
  356.       Begin VB.Menu mnuFileRemoveDir 
  357.          Caption         =   "Remove Directory"
  358.       End
  359.       Begin VB.Menu mnuFileRenameDir 
  360.          Caption         =   "Rename Directory"
  361.       End
  362.       Begin VB.Menu mnuFileRemoveFile 
  363.          Caption         =   "Remove File"
  364.       End
  365.       Begin VB.Menu mnuFileRenameFile 
  366.          Caption         =   "Rename File"
  367.       End
  368.       Begin VB.Menu mnuFileSep2 
  369.          Caption         =   "-"
  370.       End
  371.       Begin VB.Menu mnuFileSaveImageAsISO 
  372.          Caption         =   "&Save Image as ISO File..."
  373.       End
  374.       Begin VB.Menu mnuFileWriteDiscFromISO 
  375.          Caption         =   "&Write Disc from ISO File..."
  376.       End
  377.       Begin VB.Menu mnuFileSep3 
  378.          Caption         =   "-"
  379.       End
  380.       Begin VB.Menu mnuFileExit 
  381.          Caption         =   "Exit"
  382.          Shortcut        =   ^X
  383.       End
  384.    End
  385.    Begin VB.Menu mnuCDRecorder 
  386.       Caption         =   "&CD-Recorder"
  387.       Begin VB.Menu mnuCDRecorderEject 
  388.          Caption         =   "Eject"
  389.          Shortcut        =   ^J
  390.       End
  391.       Begin VB.Menu mnuCDRecorderCloseTray 
  392.          Caption         =   "Close Tray"
  393.          Shortcut        =   ^T
  394.       End
  395.       Begin VB.Menu mnuCDRecorderDiscInfo 
  396.          Caption         =   "Disc Information..."
  397.       End
  398.       Begin VB.Menu mnuCDRecorderEraseDisc 
  399.          Caption         =   "Erase Disc..."
  400.       End
  401.       Begin VB.Menu mnuCDRecorderImportPreviousSession 
  402.          Caption         =   "Import Previous Session"
  403.       End
  404.    End
  405.    Begin VB.Menu mnuHelp 
  406.       Caption         =   "&Help"
  407.       Begin VB.Menu mnuHelpAbout 
  408.          Caption         =   "About"
  409.       End
  410.    End
  411. Attribute VB_Name = "frmMain"
  412. Attribute VB_GlobalNameSpace = False
  413. Attribute VB_Creatable = False
  414. Attribute VB_PredeclaredId = True
  415. Attribute VB_Exposed = False
  416. Option Explicit
  417. Private mlngCurrentDrive As Long
  418. Private mblnUnloadOk As Boolean
  419. Private mblnMoving As Boolean
  420. Private Const sglSplitLimit As Single = 500
  421. '****************************************************************
  422. '****************************************************************
  423. 'COPYRIGHT 2003 NUMEDIA SOFT,INC.
  424. 'This is a sample of how you could use the DVDWriterPro control.
  425. 'There are improvements which could be made rather easily.
  426. 'Feel free to modify it as you see fit.
  427. 'This Sample Shows how to write a data CDR/W and DVD formats(ISO/Joliet)
  428. 'With DVDWriterPro
  429. Private Sub chkCacheImage_Click()
  430.     'Warn of DVD caching
  431.     If chkCacheImage.Value = vbChecked Then
  432.         MsgBox "Caching an image for a DVD format is not recommended and is limited to 4.2GB!", vbInformation + vbOKOnly, App.Title
  433.     End If
  434. End Sub
  435. Private Sub DVDWriterPro1_EnumISOItems(ByVal sParentDestPath As String, ByVal sItemDestPath As String, ByVal sItemName As String, ByVal sSourceFilePath As String, ByVal bIsDirectory As Boolean, ByVal dteFileDate As Date, ByVal lFileSize As Long)
  436.     Dim lstItem As ListItem
  437.     'If a file get some file attributes and add to the list.
  438.     'We wont add directories to the list view in this sample...
  439.     'It will suffice to have directories in the TreeView only!
  440.     If bIsDirectory = False Then
  441.         'Add to the list
  442.         Set lstItem = lvwImageFiles.ListItems.Add(, sItemDestPath, sItemName, "FILE", "FILE")
  443.         lstItem.SubItems(1) = Format(lFileSize / 1000, "###,###,##0.00") & " KB"
  444.         lstItem.SubItems(2) = Format(dteFileDate, "MM/DD/YYYY hh:mm:ss AMPM")
  445.     End If
  446. End Sub
  447. Private Sub DVDWriterPro1_ISODestPathChanged(ByVal sOldDestPath As String, ByVal sNewDestPath As String, ByVal bIsDirectory As Boolean)
  448.     'When a Path has changed (via renaming a directory or file), its
  449.     'Destination path is modified to reflect the new image tree.
  450.     'this event allows you to update image items with thier new destination
  451.     'paths. Since the paths are used as the keys for our tree and list, these need
  452.     'to be updated. We will change directory keys, and reload the file list.
  453.     If bIsDirectory = True Then
  454.         'Update the directory's key after the renaming
  455.         tvwDirectories.Nodes(sOldDestPath).Key = sNewDestPath
  456.     End If
  457. End Sub
  458. Private Sub DVDWriterPro1_ISOImageReset()
  459.     'Call reset routine
  460.     Call ResetImage
  461. End Sub
  462. Private Sub DVDWriterPro1_ISOItemAdded(ByVal sParentDestPath As String, ByVal sItemDestPath As String, ByVal sItemName As String, ByVal SourceFilePath As String, ByVal bIsDirectory As Boolean, ByVal dteFileDate As Date, ByVal lFileSize As Long)
  463.     'We are going to add directories to the tree
  464.     'We don't need to worry about files because they
  465.     'are handled by the EnumerateISOItems method as a particular
  466.     'directory is selected.
  467.     If bIsDirectory = True Then
  468.         Call tvwDirectories.Nodes.Add(sParentDestPath, tvwChild, sItemDestPath, sItemName, "CLOSEDFOLDER", "OPENFOLDER")
  469.         sbrStatus.Panels(1).Text = "Adding...." & sItemDestPath
  470.     End If
  471.     DoEvents
  472. End Sub
  473. Private Sub DVDWriterPro1_ISOItemRemoved(ByVal sDestinationPath As String, ByVal sItemName As String, ByVal bIsDirectory As Boolean)
  474.     If bIsDirectory = True Then
  475.         'Remove the node from the tree...all child nodes are also deleted
  476.         Call tvwDirectories.Nodes.Remove(sDestinationPath)
  477.     End If
  478. End Sub
  479. Private Sub DVDWriterPro1_ISOItemRenamed(ByVal sOldDestPath As String, ByVal sNewDestPath As String, ByVal sNewItemName As String, ByVal bIsDirectory As Boolean)
  480.     'We don't need this event in this sample because the Tree/list controls handle
  481.     'updating the new item names after renaming is complete.
  482. End Sub
  483. Private Sub DVDWriterPro1_ReadingTrackFile(ByVal sFileName As String, ByVal lFileIndex As Long, ByVal lTrackNumber As Long)
  484.     sbrStatus.Panels(1).Text = "Track: " & Format(lTrackNumber, "0#") & " - Reading..." & CStr(lFileIndex) & " - " & sFileName
  485. End Sub
  486. Private Sub DVDWriterPro1_ReadingTrackFileError(ByVal TrackFileError As DVDRPROXLibCtl.eTrackFileError, ByVal sFileName As String, ByVal lTrackNumber As Long)
  487.     Dim strErrorMsg As String
  488.     'Get the error message from public function in module 'Globals'
  489.     strErrorMsg = GetTrackFileErrorMessage(TrackFileError, sFileName)
  490.     'Show error message in the status bar...an error will also be raised as a write error
  491.     sbrStatus.Panels(1).Text = "ERROR:" & sFileName
  492.     Debug.Print "FileError - " & sFileName & CStr(TrackFileError), CStr(lTrackNumber)
  493. End Sub
  494. Private Sub DVDWriterPro1_ReplaceImportedISOFile(ByVal sDestPath As String, ByVal sNewSourcePath As String, ByVal sFileName As String, bReplaceFile As Boolean)
  495.     Dim lngResult As Long
  496.     'Should we replcae the imported file
  497.     lngResult = MsgBox("Imported file from the last session on this disc: " & vbCrLf & sDestPath & vbCrLf & _
  498.                     "Would you like to replace it with: " & vbCrLf & sNewSourcePath & " ?", vbOKCancel + vbQuestion, "Replace imported file...")
  499.     'Set the replacement flag by reference
  500.     If lngResult = vbOK Then
  501.         bReplaceFile = True
  502.     Else
  503.         bReplaceFile = False
  504.     End If
  505. End Sub
  506. Private Sub DVDWriterPro1_PreparingToWrite()
  507.         'Display status
  508.         sbrStatus.Panels(1).Text = "Preparing to Write...."
  509.         prgTotalProgress.Value = 0
  510.         'Disable buttons as we start to write
  511.         Call EnableForm(False)
  512. End Sub
  513. Private Sub DVDWriterPro1_CreatingDirectories()
  514.     sbrStatus.Panels(1).Text = "Creating Directories...."
  515. End Sub
  516. Private Sub DVDWriterPro1_ClosingDisc()
  517.     sbrStatus.Panels(1).Text = "Closing Disc...."
  518. End Sub
  519. Private Sub DVDWriterPro1_ClosingSession()
  520.     sbrStatus.Panels(1).Text = "Closing Session...."
  521. End Sub
  522. Private Sub DVDWriterPro1_ClosingTrack(ByVal lTrackNumber As Long)
  523.     sbrStatus.Panels(1).Text = "Closing Track...."
  524. End Sub
  525. Private Sub DVDWriterPro1_CachingStatus(ByVal nPercentComplete As Integer)
  526.     'Show the progress of caching the ISO/Joliet image
  527.     sbrStatus.Panels(2).Text = "Caching - " & Format(nPercentComplete, "0#") & " %"
  528. End Sub
  529. Private Sub DVDWriterPro1_TrackWriteStatus(ByVal lTrackNumber As Long, ByVal lBlocksWritten As Long, ByVal lBlocksToWrite As Long)
  530.     Dim intPercentTrackWritten As Integer
  531.     On Error Resume Next
  532.     'Calc Percent of Current track done
  533.     intPercentTrackWritten = ((lBlocksWritten / lBlocksToWrite) * 100)
  534.     'Set Progress Bars
  535.     prgTotalProgress.Value = intPercentTrackWritten
  536. End Sub
  537. Private Sub DVDWriterPro1_WriteCancelled()
  538.     'Inform user of cancelled write
  539.     sbrStatus.Panels(1).Text = "Writing Cancelled......"
  540.     Call EnableForm(True)
  541.     'Completed Message
  542.     MsgBox "Writing Cancelled!", vbInformation + vbOKOnly, App.Title
  543. End Sub
  544. Private Sub DVDWriterPro1_WriteComplete()
  545.     'Inform user of writing complete
  546.     sbrStatus.Panels(1).Text = "Writing Complete!"
  547.     'Enable the form
  548.     Call EnableForm(True)
  549.     'Completed Message
  550.     MsgBox "Writing is complete!", vbInformation + vbOKOnly, App.Title
  551.     'If not in test mode..eject
  552.     If DVDWriterPro1.TestWrite = False Then
  553.         'Eject disc
  554.         Call DVDWriterPro1.EjectLoad(False)
  555.     End If
  556. End Sub
  557. Private Sub DVDWriterPro1_WriteError(ByVal WriteError As DVDRPROXLibCtl.eWriteErrorType, ByVal DriveError As DVDRPROXLibCtl.eCDError, ByVal sErrorInfo As String, ByVal sSenseInfo As String)
  558.     Dim strError As String
  559.     'Get the error type and
  560.     strError = "Writing Error: (" & CStr(WriteError) & ")   " & sErrorInfo & vbCrLf
  561.     'If it is a drive error, add the drive error information
  562.     'to the displayed message
  563.     If WriteError = errDriveError Then
  564.         strError = strError & GetDriveErrorMessage(DriveError) & vbCrLf & " Error Sense Data: " & sSenseInfo
  565.     End If
  566.     'Display Msg to user
  567.     MsgBox strError, vbCritical + vbOKOnly
  568.     Call EnableForm(True)
  569. End Sub
  570. Private Sub cmdCancel_Click()
  571.     'Cancel recording
  572.     sbrStatus.Panels(1).Text = "Aborting Write...Please Wait!"
  573.     DVDWriterPro1.CancelWrite
  574. End Sub
  575. Private Sub cmdWriteDisc_Click()
  576.     'Check for a valid Drive
  577.     If mlngCurrentDrive = -1 Then
  578.         MsgBox "A drive is not selected or does not exist.", vbInformation + vbOKOnly, App.Title
  579.         Exit Sub
  580.     End If
  581.     'Check for media loaded
  582.     If DVDWriterPro1.GetMediaType() = mtNotLoaded Then
  583.         MsgBox "Please Insert Writable Media before continuing!", vbInformation, App.Title
  584.         Exit Sub
  585.     End If
  586.     'Set the properties of the write
  587.     With DVDWriterPro1
  588.         .CloseDisc = (chkFinalizeDisc.Value = vbChecked) 'Finalize
  589.         
  590.         'Always Close session
  591.         .CloseSession = True
  592.         
  593.         'Also write Joliet Directory structures in addition to ISO structures
  594.         .VolumeType = IIf((chkUseJoliet.Value = vbChecked), vtyISO9660_JOLIET, vtyISO9660_ONLY)
  595.         .VolumeIdentifier = txtVolIdentifier.Text 'Were setting only the Volume Identifier..You could set all the volume descriptors however
  596.                 
  597.         'Use this setting if creating an image from network files or when
  598.         'creating an image with a substantial amount of small files
  599.         'Only valid for Data images (ISO/Joliet not Audio discs)
  600.         'Maximum cache is currently limited to 4.2GB by FAT32
  601.         .CacheImage = (chkCacheImage.Value = vbChecked)
  602.         
  603.         'Use Burn Proof/JustLink on this write?
  604.         .SetBufferProtection (chkUseBurnProof.Value = vbChecked)
  605.         
  606.           'Dont allow DVDHighComp mode or Mode2XA on CD/CDRW media
  607.         If (DVDWriterPro1.GetMediaType() = mtCD) Or (DVDWriterPro1.GetMediaType() = mtCDRW) Then
  608.             .DVDHighCompatibilityMode = False
  609.             'wtpDataMode2_XA has been added for backward compatibility
  610.             'wtpDataMode1 is the standard for ISO9660 data disc.
  611.             .WriteType = IIf((chkUseMode2XA.Value = vbChecked), wtpDataMode2_XA, wtpDataMode1)
  612.             'NOT VALID For DVD formats CD ONLY
  613.             .TestWrite = (chkTestWrite.Value = vbChecked) 'Only write in test mode
  614.         Else
  615.             'DVD High Comp mode will pad the volume to at least 1GB
  616.             'This should only be used for the first session and only
  617.             'For DVD formats
  618.             'Maximum image size is currently limited to 4.2GB by FAT32
  619.             .DVDHighCompatibilityMode = (chkDVDHighCompMode.Value = vbChecked)
  620.             'wtpDataMode1 is the standard for ISO9660 DVD data disc.
  621.             .WriteType = wtpDataMode1
  622.             'Test mode NOT VALID For DVD formats - CD ONLY
  623.             .TestWrite = False
  624.         End If
  625.     End With
  626.     'Start the disc writing process..this should always return True
  627.     'Finally - Write the disc....
  628.     If DVDWriterPro1.WriteDisc() = False Then
  629.         MsgBox "Disc Write could not be started.", vbCritical, App.Title
  630.     End If
  631. End Sub
  632. Private Sub Form_Load()
  633.     'Display Version
  634.     Me.Caption = "Sample1 DVDWriterPro - Version " & DVDWriterPro1.GetVersion()
  635.     'VERY IMPORTANT - Initialize the drives
  636.     'The control will not function properly without calling this function first
  637.     'Optiontally you can use ASPI for NT, but not recommended
  638.     If DVDWriterPro1.InitDrives(False) = False Then
  639.         MsgBox "Drives Cannot be initialized...Contact support!"
  640.     End If
  641.         
  642. '*************** ENABLE LOGGING CODE
  643. '    This is how you enable logging if you need it
  644. '    'Enable logging?
  645. '    If DVDWriterPro1.SetLogging("C:\DVDTestlog.txt", True) = False Then
  646. '        MsgBox "Error enabling logging!"
  647. '    End If
  648. '*************** END LOGGING CODE
  649.     'Load the Drives
  650.     LoadDriveCombo
  651.     'Set image List for directory tree
  652.     Set tvwDirectories.ImageList = ImageList1
  653.     'Set image list for lisy view
  654.     Set lvwImageFiles.SmallIcons = ImageList1
  655.     'Clear the ISO Image..reset event will fire to prepare the GUI
  656.     Call DVDWriterPro1.ClearISOImage
  657.     'Make sure the form is enabled
  658.     Call EnableForm(True)
  659. End Sub
  660. Private Sub Form_Unload(Cancel As Integer)
  661.     'Don't Unload if we are writing
  662.     Cancel = Not mblnUnloadOk
  663. End Sub
  664. Private Sub lvwImageFiles_AfterLabelEdit(Cancel As Integer, NewString As String)
  665.     'Validate the name with simple validation
  666.     If ValidateISONames(NewString) = False Then
  667.         Cancel = 1
  668.         Exit Sub
  669.     End If
  670.     'Rename the item in the list
  671.     'the Item rename event will let us change the file list.
  672.     'If the name already exists...this will return False
  673.     If DVDWriterPro1.RenameISOFile(lvwImageFiles.SelectedItem.Key, NewString) = False Then
  674.         MsgBox "File could not be renamed.", vbInformation + vbOKOnly, App.Title
  675.     End If
  676.     'Update the image display
  677.     Call UpdateImage
  678. End Sub
  679. Private Function ValidateISONames(strNewName As String) As Boolean
  680.     Dim strFileName As String
  681.     Dim strExt As String
  682.     Dim intExtPos As Integer
  683.     'Default to false
  684.     ValidateISONames = False
  685.     'Get the name and extension to validate the file or directory name.
  686.     'We have used very simple validation for this sample...
  687.     'see the ISO9660 specification for complete validation rules.
  688.     'Get the position of the '.'
  689.     intExtPos = InStr(1, strNewName, ".", vbTextCompare)
  690.     'Do we have an extension?
  691.     If intExtPos > 0 Then
  692.         strFileName = Left$(strNewName, intExtPos)
  693.         strExt = Mid$(strNewName, intExtPos)
  694.     Else
  695.         strFileName = strNewName
  696.     End If
  697.     'Check for a zero length name
  698.     If Len(strFileName) = 0 Then
  699.         MsgBox "Item name cannot be blank.", vbInformation + vbOKOnly, App.Title
  700.         Exit Function
  701.     End If
  702.     'The file name should be validated here to ISO or Joliet standards
  703.     'ISO (Level1) - 8 character Filename + 3 extension
  704.     'ISO (Level2) - 31 character max including extension
  705.     'Joliet - 64 character max including extension
  706.     'Validate Joliet names
  707.     If (Len(strNewName) > 64) And (DVDWriterPro1.VolumeType = vtyISO9660_JOLIET) Then
  708.         MsgBox "Item Name violates Joliet naming rules (64 Char Max).", vbInformation + vbOKOnly, App.Title
  709.         Exit Function
  710.     End If
  711.     'Validate ISO Level 1 name......MOST COMMON to all Operating systems
  712.     If (DVDWriterPro1.VolumeType = vtyISO9660_JOLIET) And (DVDWriterPro1.ISOComplianceLevel = lvISO9660Level_1) Then
  713.         If (Len(strFileName) > 8) Or (Len(strExt) > 3) Then
  714.             MsgBox "Item Name violates ISO9660 Level 1 naming rules (8 + 3 Char Max).", vbInformation + vbOKOnly, App.Title
  715.             Exit Function
  716.         End If
  717.     End If
  718.     'Validate ISO Level 2 name
  719.     If (Len(strNewName) > 31) And (DVDWriterPro1.VolumeType = vtyISO9660_JOLIET) And (DVDWriterPro1.ISOComplianceLevel <> lvISO9660Level_1) Then
  720.         MsgBox "Item Name violates ISO9660 Level 2 naming rules (31 Char Max).", vbInformation + vbOKOnly, App.Title
  721.         Exit Function
  722.     End If
  723.     'Else we passed the validation
  724.     ValidateISONames = True
  725. End Function
  726. Private Sub lvwImageFiles_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  727.     'Pop up menu
  728.     If Button = vbRightButton Then
  729.         'Hide items
  730.         mnuFileSep1.Visible = False
  731.         'Hide Directory name edit
  732.         mnuFileRemoveDir.Visible = False
  733.         mnuFileRenameDir.Visible = False
  734.         mnuFileSep2.Visible = False
  735.         mnuFileSaveImageAsISO.Visible = False
  736.         mnuFileWriteDiscFromISO.Visible = False
  737.         mnuFileSep3.Visible = False
  738.         mnuFileExit.Visible = False
  739.         'Pop the menu
  740.         PopupMenu mnuFile
  741.         'Show items
  742.         mnuFileSep1.Visible = True
  743.         mnuFileRemoveDir.Visible = True
  744.         mnuFileRenameDir.Visible = True
  745.         mnuFileSep2.Visible = True
  746.         mnuFileSaveImageAsISO.Visible = True
  747.         mnuFileWriteDiscFromISO.Visible = True
  748.         mnuFileSep3.Visible = True
  749.         mnuFileExit.Visible = True
  750.     End If
  751. End Sub
  752. Private Sub mnuCDRecorderCloseTray_Click()
  753.     Call DVDWriterPro1.EjectLoad(True)
  754. End Sub
  755. Private Sub mnuCDRecorderDiscInfo_Click()
  756.     'Show disc information form - do modal from this function
  757.     Call frmDiscInfo.ShowDiscInfo(DVDWriterPro1, Me)
  758. End Sub
  759. Private Sub mnuCDRecorderEject_Click()
  760.     Call DVDWriterPro1.EjectLoad(False)
  761. End Sub
  762. Private Sub mnuCDRecorderEraseDisc_Click()
  763.     'Ersae the disc - Rewritable only
  764.     Call frmErase.ShowErase(DVDWriterPro1)
  765. End Sub
  766. Private Sub mnuCDRecorderImportPreviousSession_Click()
  767.     'Check for a valid Drive
  768.     If mlngCurrentDrive = -1 Then
  769.         MsgBox "A drive is not selected or does not exist.", vbInformation + vbOKOnly, App.Title
  770.         Exit Sub
  771.     End If
  772.     'Check for media loaded
  773.     If DVDWriterPro1.GetMediaType() = mtNotLoaded Then
  774.         MsgBox "Please Insert a disc before continuing!", vbInformation, App.Title
  775.         Exit Sub
  776.     End If
  777.     'Display status
  778.     sbrStatus.Panels(1).Text = "Importing Previous Session..."
  779.     'ONLY MODE1 ISO or Joliet Volumes can be imported
  780.     'Attempt to import the previous session
  781.     If DVDWriterPro1.ImportISOTrack(True) = False Then
  782.         MsgBox "Previous Session could not be imported" & vbCrLf & "Only ISO/Joliet tracks (Mode1) can be imported.", vbCritical, App.Title
  783.         Exit Sub
  784.     End If
  785.     'Change Volume ID to new Volume Identifier
  786.     txtVolIdentifier.Text = DVDWriterPro1.VolumeIdentifier
  787.     'Expan the node
  788.     If tvwDirectories.Nodes.Count > 0 Then
  789.         tvwDirectories.Nodes(1).Expanded = True
  790.     End If
  791.     'If we suceeded...Update image List
  792.     Call UpdateImage
  793. End Sub
  794. Private Sub mnuFileClear_Click()
  795.     'Clear the ISO Image..reset event will fire to prepare the GUI
  796.     Call DVDWriterPro1.ClearISOImage
  797. End Sub
  798. Private Sub ResetImage()
  799.     'Clear File List
  800.     Call lvwImageFiles.ListItems.Clear
  801.     'Clear the directory nodes
  802.     Call tvwDirectories.Nodes.Clear
  803.     'Default the Volume Identifier to 'New Disc'
  804.     DVDWriterPro1.VolumeIdentifier = "New Disc"
  805.     'Add a root node for the root image directory
  806.     Call tvwDirectories.Nodes.Add(, , "\", DVDWriterPro1.VolumeIdentifier, "CD", "CD")
  807.     txtVolIdentifier.Text = DVDWriterPro1.VolumeIdentifier
  808.     'Recalc image size
  809.     Call RecalcImageSize
  810. End Sub
  811. Private Sub mnuFileExit_Click()
  812.     Unload Me
  813. End Sub
  814. Private Sub mnuFileRemoveDir_Click()
  815.     Dim nodItem As Node
  816.     Dim strKey As String
  817.     Set nodItem = tvwDirectories.SelectedItem
  818.     'Check for an item
  819.     If nodItem Is Nothing Then
  820.         MsgBox "No Item Selected.", vbInformation + vbOKOnly, App.Title
  821.         Exit Sub
  822.     End If
  823.     'Get the key
  824.     strKey = nodItem.Key
  825.     'Remove the item from the tree
  826.     'the Item removed event will let us change the list
  827.     If DVDWriterPro1.RemoveISOItem(strKey) = False Then
  828.         MsgBox "Item could not be removed.", vbInformation + vbOKOnly, App.Title
  829.     End If
  830.     'Update The image display
  831.     Call UpdateImage
  832. End Sub
  833. Private Sub mnuFileRemoveFile_Click()
  834.     Dim lstItem As ListItem
  835.     Set lstItem = lvwImageFiles.SelectedItem
  836.     'Check for an item
  837.     If lstItem Is Nothing Then
  838.         MsgBox "No Item Selected.", vbInformation + vbOKOnly, App.Title
  839.         Exit Sub
  840.     End If
  841.     'Remove the item from the list
  842.     'the Item removed event will let us change the list
  843.     If DVDWriterPro1.RemoveISOItem(lstItem.Key) = False Then
  844.         MsgBox "Item could not be removed.", vbInformation + vbOKOnly, App.Title
  845.     End If
  846.     'Update The image display
  847.     Call UpdateImage
  848. End Sub
  849. Private Sub mnuFileRenameDir_Click()
  850.     Dim nodItem As Node
  851.     Set nodItem = tvwDirectories.SelectedItem
  852.     'Check for an item
  853.     If nodItem Is Nothing Then
  854.         MsgBox "No Item Selected.", vbInformation + vbOKOnly, App.Title
  855.         Exit Sub
  856.     End If
  857.     'Let the user modify the name
  858.     Call tvwDirectories.StartLabelEdit
  859. End Sub
  860. Private Sub mnuFileRenameFile_Click()
  861.     Dim lstItem As ListItem
  862.     Set lstItem = lvwImageFiles.SelectedItem
  863.     'Check for an item
  864.     If lstItem Is Nothing Then
  865.         MsgBox "No Item Selected.", vbInformation + vbOKOnly, App.Title
  866.         Exit Sub
  867.     End If
  868.     'Let the user modify the file
  869.     Call lvwImageFiles.StartLabelEdit
  870. End Sub
  871. Private Sub mnuFileSaveImageAsISO_Click()
  872.     Dim blnSuccess As Boolean
  873.     On Error GoTo ErrorHandler
  874.     'Get filename for extracted Files
  875.     CommonDialog1.DialogTitle = "Save as ISO File"
  876.     CommonDialog1.FileName = "Test.iso"
  877.     CommonDialog1.Filter = "ISO file (*.iso)|*.iso"
  878.     CommonDialog1.Flags = cdlOFNNoValidate
  879.     CommonDialog1.CancelError = True
  880.     CommonDialog1.ShowOpen
  881.     'Disable Form
  882.     Call EnableForm(False)
  883.     With DVDWriterPro1
  884.                         
  885.         'Also write Joliet Directory structures in addition to ISO structures
  886.         .VolumeType = IIf((chkUseJoliet.Value = vbChecked), vtyISO9660_JOLIET, vtyISO9660_ONLY)
  887.         .VolumeIdentifier = txtVolIdentifier.Text 'Were setting only the Volume Identifier..You could set all the volume descriptors however
  888.         
  889.         'Dont allow DVDHighComp mode or Mode2XA on CD/CDRW media
  890.         If (DVDWriterPro1.GetMediaType() = mtCD) Or (DVDWriterPro1.GetMediaType() = mtCDRW) Then
  891.             .DVDHighCompatibilityMode = False
  892.             'wtpDataMode2_XA has been added for backward compatibility
  893.             'wtpDataMode1 is the standard for ISO9660 data disc.
  894.             .WriteType = IIf((chkUseMode2XA.Value = vbChecked), wtpDataMode2_XA, wtpDataMode1)
  895.         Else
  896.             'DVD High Comp mode will pad the volume to at least 1GB
  897.             'This should only be used for the first session and only
  898.             'For DVD formats
  899.             'Maximum image size is currently limited to 4.2GB by FAT32
  900.             .DVDHighCompatibilityMode = (chkDVDHighCompMode.Value = vbChecked)
  901.             'wtpDataMode1 is the standard for ISO9660 DVD data disc.
  902.             .WriteType = wtpDataMode1
  903.         End If
  904.     End With
  905.     'Save the file as an ISO file
  906.     blnSuccess = DVDWriterPro1.CreateISOImageFile(CommonDialog1.FileName)
  907.     'Enable Form
  908.     Call EnableForm(True)
  909.     'Check if successful
  910.     If blnSuccess = True Then
  911.         MsgBox "ISO File Created successfully!", vbOKOnly + vbInformation, App.Title
  912.     Else
  913.         MsgBox "Error creating ISO File.", vbCritical, App.Title
  914.     End If
  915.     'Recalc Image size..show correct display
  916.     Call RecalcImageSize
  917.     Exit Sub
  918. ErrorHandler:
  919.     'No error on Cancel
  920.     'Enable Form
  921.     Call EnableForm(True)
  922. End Sub
  923. Private Sub mnuFileWriteDiscFromISO_Click()
  924.     Dim blnSuccess As Boolean
  925.     On Error GoTo ErrorHandler
  926.     'Get filename for extracted Files
  927.     CommonDialog1.DialogTitle = "Write ISO File"
  928.     CommonDialog1.FileName = "Test.iso"
  929.     CommonDialog1.Filter = "ISO file (*.iso)|*.iso"
  930.     CommonDialog1.Flags = cdlOFNNoValidate
  931.     CommonDialog1.CancelError = True
  932.     CommonDialog1.ShowOpen
  933.     'Disable Form
  934.     Call EnableForm(False)
  935.     'Set the properties of the write
  936.     With DVDWriterPro1
  937.         
  938.         'You should make sure the image matches Mode1 or Mode2?
  939.         'wtpDataMode2_XA has been added for backward compatibility
  940.         'wtpDataMode1 is the standard for ISO9660 data disc.
  941.         .WriteType = IIf((chkUseMode2XA.Value = vbChecked), wtpDataMode2_XA, wtpDataMode1)
  942.         .CloseDisc = (chkFinalizeDisc.Value = vbChecked) 'Finalize
  943.         
  944.         'Always Close session
  945.         .CloseSession = True
  946.                 
  947.         'NOT VALID For DVD formats
  948.         .TestWrite = (chkTestWrite.Value = vbChecked) 'Only write in test mode
  949.         
  950.         'Use Burn Proof/JustLink on this write?
  951.         .SetBufferProtection (chkUseBurnProof.Value = vbChecked)
  952.     End With
  953.     'Save the file as an ISO file
  954.     If DVDWriterPro1.WriteISOImage(CommonDialog1.FileName) = False Then
  955.         Call EnableForm(True)
  956.         MsgBox "Error Writing ISO File.", vbCritical, App.Title
  957.     End If
  958.     Exit Sub
  959. ErrorHandler:
  960.     'No error on Cancel
  961.     'Enable Form
  962.     Call EnableForm(True)
  963. End Sub
  964. Private Sub mnuHelpAbout_Click()
  965. '    DVDWriterPro1.AboutBox
  966. End Sub
  967. Private Sub LoadDriveCombo()
  968.     Dim intDrives As Integer
  969.     'Clear Drive Combo
  970.     cboDevices.Clear
  971.     'Default to invalid drive
  972.     mlngCurrentDrive = -1
  973.     'Get the ONLY recordable drives
  974.     For intDrives = 0 To DVDWriterPro1.GetDriveCount() - 1
  975.         
  976.         'Is recorder - all drives are reported not just writers
  977.         'so we need to save the index so we know which drive to open
  978.         If DVDWriterPro1.IsDriveWriter(intDrives) = True Then
  979.             cboDevices.AddItem DVDWriterPro1.GetDriveLetter(intDrives) & ": " & DVDWriterPro1.GetDriveVendor(intDrives) & " " & DVDWriterPro1.GetDriveModel(intDrives)
  980.             cboDevices.ItemData(cboDevices.NewIndex) = intDrives
  981.         End If
  982.     Next
  983.     'Set to first CDR
  984.     If cboDevices.ListCount > 0 Then
  985.         cboDevices.ListIndex = 0
  986.     Else
  987.         MsgBox "There are no compatible CDR drives reported." & vbCrLf & _
  988.                 "Some older CDR drives are not currently supported.", vbInformation + vbOKOnly, App.Title
  989.     End If
  990. End Sub
  991. Private Sub cboDevices_Click()
  992.     Dim lngDriveIndex As Long
  993.     'Set Drive Index from the Item Data
  994.     lngDriveIndex = cboDevices.ItemData(cboDevices.ListIndex)
  995.     'Open the Drive for use..we have already screened out
  996.     'non writing drives when we loaded the drive combo
  997.     If DVDWriterPro1.OpenDrive(lngDriveIndex) = False Then
  998.         mlngCurrentDrive = -1
  999.     Else
  1000.         mlngCurrentDrive = lngDriveIndex
  1001.     End If
  1002.     'Load speeds for this drive
  1003.     LoadWriteSpeedCombo
  1004.     'Set Burn Proof Check
  1005.     If DVDWriterPro1.GetDriveCapabilityFlag(SupportsBurnProof) = True Then
  1006.         chkUseBurnProof.Enabled = True
  1007.         chkUseBurnProof.Value = vbChecked
  1008.     Else
  1009.         chkUseBurnProof.Enabled = False
  1010.         chkUseBurnProof.Value = vbUnchecked
  1011.     End If
  1012. End Sub
  1013. Private Sub cboWriteSpeed_Click()
  1014.     'Check for speeds being available
  1015.     If cboWriteSpeed.Text <> "Default" Then
  1016.         'Set Drive Speed
  1017.         DVDWriterPro1.SetWriteSpeed cboWriteSpeed.ItemData(cboWriteSpeed.ListIndex)
  1018.     End If
  1019. End Sub
  1020. Private Sub LoadWriteSpeedCombo()
  1021.     Dim lngMaxWriteSpeedKBS As Long
  1022.     Dim lngSpeedKBS As Long
  1023.     Dim dblDisplaySpeed  As Double
  1024.     Dim bUseDVDspeeds As Boolean
  1025.     Dim DiscType As eMediaType
  1026.     'Get Max Write Speed in KB/S not as a multiplier.
  1027.     'DVD and CD have different writing rates to calculate multipliers
  1028.     'We must use the helper function to determine a multiplier easy for
  1029.     'the user to understand
  1030.     'What kind of speed multiplier do we need to show the user
  1031.     DiscType = DVDWriterPro1.GetMediaType()
  1032.     If (DiscType = mtCD) Or (DiscType = mtCDRW) Or (DiscType = mtNotLoaded) Then
  1033.         'This will be used to calc a multiplier based on KB/s
  1034.         bUseDVDspeeds = False
  1035.     Else
  1036.         bUseDVDspeeds = True
  1037.     End If
  1038.     'Clear Combo
  1039.     cboWriteSpeed.Clear
  1040.     'Get the MAX Write speed for the loaded media in kb/s
  1041.     lngMaxWriteSpeedKBS = DVDWriterPro1.GetMaxWriteSpeed()
  1042.     'If speed is not zero then
  1043.     If lngMaxWriteSpeedKBS > 0 Then
  1044.         
  1045.         'Set our temp speed kbs to the max
  1046.         lngSpeedKBS = lngMaxWriteSpeedKBS
  1047.         
  1048.         'DVD speeds or CD speeds for display
  1049.         If bUseDVDspeeds = True Then
  1050.             Do
  1051.                 '1380 is the KB/S constant for DVD for 1X
  1052.                 dblDisplaySpeed = CDbl(lngSpeedKBS) / 1380
  1053.                 
  1054.                 'Calc a displayed Multiplier such as 2.4X for DVD
  1055.                 cboWriteSpeed.AddItem Format(dblDisplaySpeed, "#.0") & "x"
  1056.                 'Save the Kb/s in the combo
  1057.                 cboWriteSpeed.ItemData(cboWriteSpeed.NewIndex) = lngSpeedKBS
  1058.                 
  1059.                 'For DVD we will increment in .5X levels (eg - 2.4X)
  1060.                 lngSpeedKBS = lngSpeedKBS - 690
  1061.             Loop While (lngSpeedKBS >= 1380)
  1062.         Else
  1063.             Do
  1064.                 '176kbs is the KB/S constant for CD for 1X
  1065.                 dblDisplaySpeed = CDbl(lngSpeedKBS) / 176
  1066.                 
  1067.                 'Clean up displayed multiplier...some drives report speeds
  1068.                 'not in exact multiplies
  1069.                 If (dblDisplaySpeed > 0) And (dblDisplaySpeed < 2) Then
  1070.                     dblDisplaySpeed = 1
  1071.                 End If
  1072.                 
  1073.                 'Calc a displayed Multiplier such as 16X for CD
  1074.                 cboWriteSpeed.AddItem Format(dblDisplaySpeed, "#") & "x"
  1075.                 'Save the Kb/s in the combo
  1076.                 cboWriteSpeed.ItemData(cboWriteSpeed.NewIndex) = lngSpeedKBS
  1077.                 
  1078.                 'For CD we will decrement in 2X levels (eg - 8X)
  1079.                 'When we hit below 4x, then we decrement in 2X levels
  1080.                 If lngSpeedKBS >= 1200 Then
  1081.                     lngSpeedKBS = lngSpeedKBS - 704
  1082.                 Else
  1083.                     lngSpeedKBS = lngSpeedKBS - 352
  1084.                 End If
  1085.             Loop While (lngSpeedKBS > 0)
  1086.         End If
  1087.     Else
  1088.         'Some drives don't report speed
  1089.         cboWriteSpeed.AddItem "Default"
  1090.     End If
  1091.     'Set to Max
  1092.     If cboWriteSpeed.ListCount > 0 Then
  1093.         cboWriteSpeed.ListIndex = 0
  1094.     End If
  1095. End Sub
  1096. Private Function IsPathDirectory(strPath As String) As Boolean
  1097.     If (GetAttr(strPath) And vbDirectory) = vbDirectory Then
  1098.         IsPathDirectory = True
  1099.     Else
  1100.         IsPathDirectory = False
  1101.     End If
  1102. End Function
  1103. Private Sub LoadFileList(ByVal strCurrentDestPath As String)
  1104.     'Set Wait pointer
  1105.     Me.MousePointer = vbHourglass
  1106.     'Clear the List
  1107.     lvwImageFiles.ListItems.Clear
  1108.     'Enumerate Files - makes it easy to update your list
  1109.     Call DVDWriterPro1.EnumerateISOItems(strCurrentDestPath)
  1110.     'Set Wait pointer
  1111.     Me.MousePointer = vbDefault
  1112. End Sub
  1113. Private Sub EnableForm(blnEnable As Boolean)
  1114.     'Disable buttons and track view when recording
  1115.     mnuFile.Enabled = blnEnable
  1116.     mnuCDRecorder.Enabled = blnEnable
  1117.     mnuHelp.Enabled = blnEnable
  1118.     cboDevices.Enabled = blnEnable
  1119.     cboWriteSpeed.Enabled = blnEnable
  1120.     lvwImageFiles.Enabled = blnEnable
  1121.     tvwDirectories.Enabled = blnEnable
  1122.     cmdWriteDisc.Enabled = blnEnable
  1123.     chkCacheImage.Enabled = blnEnable
  1124.     chkFinalizeDisc.Enabled = blnEnable
  1125.     chkTestWrite.Enabled = blnEnable
  1126.     chkUseJoliet.Enabled = blnEnable
  1127.     txtVolIdentifier.Enabled = blnEnable
  1128.     chkDVDHighCompMode.Enabled = blnEnable
  1129.     chkUseMode2XA.Enabled = blnEnable
  1130.     'Enable the burn Proof checkbox
  1131.     If (DVDWriterPro1.GetDriveCapabilityFlag(SupportsBurnProof) = True) And (blnEnable = True) Then
  1132.         chkUseBurnProof.Enabled = True
  1133.     Else
  1134.         chkUseBurnProof.Enabled = False
  1135.     End If
  1136.     'Only enable when recording
  1137.     cmdCancel.Enabled = Not blnEnable
  1138.     mblnUnloadOk = blnEnable
  1139.     'Set Pointer
  1140.     If blnEnable = True Then
  1141.         Me.MousePointer = vbDefault
  1142.     Else
  1143.         Me.MousePointer = vbHourglass
  1144.     End If
  1145.     'Let GUI catch up
  1146.     DoEvents
  1147. End Sub
  1148. Private Sub imgSplitter_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1149.     With imgSplitter
  1150.         picSplitter.Move .Left, .Top, .Width \ 2, .Height - 20
  1151.     End With
  1152.     picSplitter.Visible = True
  1153.     mblnMoving = True
  1154. End Sub
  1155. Private Sub imgSplitter_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  1156.     Dim sglPos As Single
  1157.     If mblnMoving = True Then
  1158.         sglPos = x + imgSplitter.Left
  1159.         If (sglPos < sglSplitLimit) Then
  1160.             picSplitter.Left = sglSplitLimit
  1161.         ElseIf (sglPos > Me.Width - sglSplitLimit) Then
  1162.             picSplitter.Left = Me.Width - sglSplitLimit
  1163.         Else
  1164.             picSplitter.Left = sglPos
  1165.         End If
  1166.     End If
  1167. End Sub
  1168. Private Sub imgSplitter_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  1169.     SizeControls picSplitter.Left
  1170.     picSplitter.Visible = False
  1171.     mblnMoving = False
  1172. End Sub
  1173. Private Sub SizeControls(x As Single)
  1174.     On Error Resume Next
  1175.     'Set the width for all items
  1176.     If x < 1500 Then x = 1500
  1177.     If x > (Me.Width - 1500) Then x = Me.Width - 1500
  1178.     tvwDirectories.Width = x
  1179.     tvwDirectories.Left = 20
  1180.     imgSplitter.Left = x
  1181.     lvwImageFiles.Left = x + imgSplitter.Width
  1182.     lvwImageFiles.Width = Me.Width - (tvwDirectories.Width + imgSplitter.Width) - 100
  1183.     lblImageFileTitle.Left = tvwDirectories.Left
  1184.     lblImageFileTitle.Width = Me.Width - 140
  1185.     tvwDirectories.Top = lblImageFileTitle.Height + lblImageFileTitle.Top
  1186.     lvwImageFiles.Top = tvwDirectories.Top
  1187.     imgSplitter.Top = tvwDirectories.Top
  1188.     imgSplitter.Height = tvwDirectories.Height
  1189. End Sub
  1190. Private Sub Form_Resize()
  1191.     On Error Resume Next
  1192.     If Me.Width < 3000 Then Me.Width = 3000
  1193.     SizeControls imgSplitter.Left
  1194. End Sub
  1195. Private Sub OLEDragDrop(Data As MSComctlLib.DataObject)
  1196.     Dim strItemToAdd As String
  1197.     Dim strSelectedImagePath As String
  1198.     Dim varItem As Variant
  1199.     Dim strTempPath As String
  1200.     Dim blnIsDirectory As Boolean
  1201.     'Get only files as dropped data
  1202.     If Data.GetFormat(vbCFFiles) = False Then Exit Sub
  1203.     'Set back Mouse pointer
  1204.     Me.MousePointer = vbHourglass
  1205.     'Default to Blank
  1206.     strSelectedImagePath = ""
  1207.     'Set the selected image Path
  1208.     If Not (tvwDirectories.SelectedItem Is Nothing) Then
  1209.         'Dont include the '\' on the root so we don't have '\\'
  1210.         If tvwDirectories.SelectedItem.Key <> "\" Then
  1211.             strSelectedImagePath = tvwDirectories.SelectedItem.Key
  1212.         End If
  1213.     End If
  1214.     For Each varItem In Data.Files
  1215.         'Set Temp Item
  1216.         strTempPath = CStr(varItem)
  1217.         
  1218.         'Get the last item in the path
  1219.         strItemToAdd = GetLastPathItem(strTempPath)
  1220.         
  1221.         'If is a Directory get recursive children files and directories
  1222.         blnIsDirectory = IsPathDirectory(strTempPath)
  1223.                 
  1224.         'If it is a directory then clone the directory to the image
  1225.         If blnIsDirectory = True Then
  1226.             Call DVDWriterPro1.CloneDirectoryToISO(strSelectedImagePath & "\" & strItemToAdd, strTempPath & "\*.*")
  1227.         Else
  1228.             'If just a file add it to the image
  1229.             Call DVDWriterPro1.InsertISOItem(strSelectedImagePath & "\" & strItemToAdd, strTempPath)
  1230.         End If
  1231.     Next
  1232.     'Update the display and load file list
  1233.     Call UpdateImage
  1234.     'Set back Mouse pointer
  1235.     Me.MousePointer = vbDefault
  1236. End Sub
  1237. Private Sub UpdateImage()
  1238.     'Update the image display
  1239.     'Load file list
  1240.     If Not (tvwDirectories.SelectedItem Is Nothing) Then
  1241.         'Enumerate the Selected folder
  1242.          Call LoadFileList(tvwDirectories.SelectedItem.Key)
  1243.          'Expand selected folder
  1244.          tvwDirectories.SelectedItem.Expanded = True
  1245.     Else
  1246.         'Enumerate the root list
  1247.         Call LoadFileList("\")
  1248.         'Expand the root
  1249.         tvwDirectories.Nodes("\").Expanded = True
  1250.     End If
  1251.     'Recalc the image size
  1252.     Call RecalcImageSize
  1253. End Sub
  1254. Private Sub RecalcImageSize()
  1255.     Dim lngSizeBlocks As Long
  1256.     Dim lngSizeBytes As Double
  1257.     'Get blocks and convert to MB used in this image
  1258.     lngSizeBlocks = DVDWriterPro1.GetISOVolumeSizeBlocks()
  1259.     lngSizeBytes = DVDWriterPro1.ConvertBlocksToBytes(lngSizeBlocks, 1)
  1260.     'Show the Volume Attributes
  1261.     sbrStatus.Panels(1).Text = "Data Image Size: " & Format((lngSizeBytes / 1000000), "##0.00") & " MB  "
  1262.     sbrStatus.Panels(2).Text = "Files: " & DVDWriterPro1.GetISOFileCount()
  1263.     sbrStatus.Panels(3).Text = "Directories: " & DVDWriterPro1.GetISODirectoryCount()
  1264. End Sub
  1265. Private Sub tvwDirectories_AfterLabelEdit(Cancel As Integer, NewString As String)
  1266.     'Validate the name with simple validation
  1267.     If ValidateISONames(NewString) = False Then
  1268.         Cancel = 1
  1269.         Exit Sub
  1270.     End If
  1271.     'Rename the item in the list
  1272.     'the Item rename event will let us change the file list.
  1273.     'If the name already exists...this will return False
  1274.     'Pass the original destination path and the new directory name
  1275.     If DVDWriterPro1.RenameISODirectory(tvwDirectories.SelectedItem.Key, NewString) = False Then
  1276.         MsgBox "Directory could not be renamed.", vbInformation + vbOKOnly, App.Title
  1277.     End If
  1278.     'Update the image display
  1279.     Call UpdateImage
  1280. End Sub
  1281. Private Sub tvwDirectories_BeforeLabelEdit(Cancel As Integer)
  1282.     'Dont let the user rename the root
  1283.     If tvwDirectories.SelectedItem.Key = "\" Then
  1284.         MsgBox "Root directory can not be renamed.", vbInformation + vbOKOnly, App.Title
  1285.         Cancel = 1
  1286.     End If
  1287. End Sub
  1288. Private Sub tvwDirectories_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1289.     'Pop up menu
  1290.     If Button = vbRightButton Then
  1291.         'Hide items
  1292.         mnuFileSep1.Visible = False
  1293.         'Hide Filename edit
  1294.         mnuFileRemoveFile.Visible = False
  1295.         mnuFileRenameFile.Visible = False
  1296.         mnuFileSep2.Visible = False
  1297.         mnuFileSaveImageAsISO.Visible = False
  1298.         mnuFileWriteDiscFromISO.Visible = False
  1299.         mnuFileSep3.Visible = False
  1300.         mnuFileExit.Visible = False
  1301.         
  1302.         
  1303.         'Pop the menu
  1304.         PopupMenu mnuFile
  1305.         
  1306.         'Show items
  1307.         mnuFileSep1.Visible = True
  1308.         mnuFileRemoveFile.Visible = True
  1309.         mnuFileRenameFile.Visible = True
  1310.         mnuFileSep2.Visible = True
  1311.         mnuFileSaveImageAsISO.Visible = True
  1312.         mnuFileWriteDiscFromISO.Visible = True
  1313.         mnuFileSep3.Visible = True
  1314.         mnuFileExit.Visible = True
  1315.     End If
  1316. End Sub
  1317. Private Sub tvwDirectories_NodeClick(ByVal Node As MSComctlLib.Node)
  1318.     'Load the current directories files
  1319.     Call LoadFileList(Node.Key)
  1320. End Sub
  1321. Private Sub tvwDirectories_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
  1322.     'Call generic drag and drop function
  1323.     Call OLEDragDrop(Data)
  1324. End Sub
  1325. Private Sub lvwImageFiles_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
  1326.     'Call generic drag and drop function
  1327.     Call OLEDragDrop(Data)
  1328. End Sub
  1329. Private Function GetLastPathItem(strPath As String) As String
  1330.     Dim strTemp As String
  1331.     Dim intPos As Integer
  1332.     'Find first path seperator in reverse
  1333.     intPos = InStrRev(strPath, "\")
  1334.     strTemp = Right(strPath, Len(strPath) - intPos)
  1335.     GetLastPathItem = strTemp
  1336. End Function
  1337. Private Sub txtVolIdentifier_Change()
  1338.     'Set the root text to the new identifier
  1339.     tvwDirectories.Nodes("\").Text = txtVolIdentifier.Text
  1340. End Sub
  1341.